package com.paas.demo.shiro;

import lombok.Data;
import org.apache.shiro.authc.RememberMeAuthenticationToken;

/**
 * @author : pengjie
 * @PackageName : cn.ztotech.ad.shiro
 * @Description : TODO
 * @email : 627799251@qq.com
 * @Date : 2019/5/24 15:39
 */
@Data
public class ShiroUserToken  implements RememberMeAuthenticationToken {

    /**
     * The username
     */
    private String username;

    /**
     * The password, in char[] format
     */
    private char[] password;

    private TokenType tokentype;

    private boolean rememberMe = false;

    public ShiroUserToken(final String username, final String password, final boolean rememberMe, TokenType tokentype) {
        this(username, password != null ? password.toCharArray() : null, rememberMe, tokentype);
    }
    public ShiroUserToken(final String username, final char[] password, final boolean rememberMe, final TokenType tokentype) {

        this.username = username;
        this.password = password;
        this.rememberMe = rememberMe;
        this.tokentype = tokentype;
    }

    @Override
    public boolean isRememberMe() {
        return false;
    }

    @Override
    public Object getPrincipal() {
        return getUsername();
    }

    @Override
    public Object getCredentials() {
        return getPassword();
    }

    public enum TokenType{
        app, sys, tv
    }
}
